package item;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class DefaultItemTemplate implements ItemTemplate {

	int bindType;
	String desc;
	int category;
	int group;
	int icon;
	int id;
	int level;
	int maxCount;
	String name;
	int price;
	int quality;
	int useLevel;
	ItemUseType useType;
	boolean isQuestItem;
	boolean newInstance;
	int obsoleteType;
	int obsoleteTime;
	//ExpressionList additionalCondition;
	String additionalPrompt;
    
	public DefaultItemTemplate(int id){
		this.id = id;
	}
	
	/*public ExpressionList getAdditionalCondition(){
		return additionalCondition;
	}
	
	public void setAdditionalCondition(ExpressionList additionalCondition){
		this.additionalCondition = additionalCondition;
	}*/
	
	public int getBindType() {
		return bindType;
	}
	public void setBindType(int bindType) {
		this.bindType = bindType;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public int getCategory() {
		return category;
	}
	public void setCategory(int cate) {
		category = cate;
	}
	public int getGroup() {
		return group;
	}
	public void setGroup(int group) {
		this.group = group;
	}
	public int getIcon() {
		return icon;
	}
	public void setIcon(int icon) {
		this.icon = icon;
	}
	public int getId() {
		return id;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public int getMaxCount() {
		return maxCount;
	}
	public void setMaxCount(int maxCount) {
		this.maxCount = maxCount;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	public int getQuality() {
		return quality;
	}
	public void setQuality(int quality) {
		this.quality = quality;
	}
	public int getUseLevel() {
		return useLevel;
	}
	public void setUseLevel(int useLevel) {
		this.useLevel = useLevel;
	}
	public ItemUseType getUseType() {
		return useType;
	}
	public void setUseType(ItemUseType useType) {
		this.useType = useType;
	}
	public boolean isQuestItem() {
		return isQuestItem;
	}
	public void setQuestItem(boolean isQuestItem) {
		this.isQuestItem = isQuestItem;
	}
	public boolean isNewInstance() {
		return newInstance;
	}
	public void setNewInstance(boolean newInstance) {
		this.newInstance = newInstance;
	}
	
	public int getObsoleteType(){
		return this.obsoleteType;
	}
	
	public void setObsoleteType(int obsoleteType){
		this.obsoleteType = obsoleteType;
	}
	
	public int getObsoleteTime(){
		return this.obsoleteTime;
	}
	
	public void setObsoleteTime(int obsoleteTime){
		this.obsoleteTime = obsoleteTime;
	}

	public byte[] toClientBytes(){
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		try {
			dos.writeInt(id);
			writeByteEquipPart(dos);
		} catch (IOException e) {
		}
		return baos.toByteArray();
	}
	
	protected void writeByteEquipPart(DataOutputStream dos)
	{
		
	}
	
	@Override
	public void reset(ItemTemplate otherTemplate){
		this.bindType = otherTemplate.getBindType();
		this.desc = otherTemplate.getDesc();
		this.category = otherTemplate.getCategory();
		this.group = otherTemplate.getGroup();
		this.icon  = otherTemplate.getIcon();
		this.id  = otherTemplate.getId();
		this.level = otherTemplate.getLevel();
		this.maxCount = otherTemplate.getMaxCount();
		this.name = otherTemplate.getName();
		this.price = otherTemplate.getPrice();
		this.quality  = otherTemplate.getQuality();
		this.useLevel = otherTemplate.getUseLevel();
		this.useType = otherTemplate.getUseType();
		this.isQuestItem = otherTemplate.isQuestItem();
		this.newInstance = otherTemplate.isNewInstance();
	}

	@Override
	public boolean hasEffect() {
		return false;
	}

	@Override
	public String getAdditionalPrompt() {
		return additionalPrompt;
	}
	
	public void setAdditionalPrompt(String additionalPrompt){
		this.additionalPrompt = additionalPrompt;
	}
}
